home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / Development / TinyGL / ami / content / ad709 / tinygl / examples / c / test1.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-08-15  |  1.3 KB  |  69 lines

  1. #include <stdio.h>
  2. #include <stdarg.h>
  3. #include <string.h>
  4. #include <stdlib.h>
  5. #include <ad709/tinygl/glut.h>
  6.  
  7. void init(void)     {
  8.     glClearColor(0.0, 0.0, 0.0, 0.0) ;
  9.     glShadeModel(GL_FLAT) ;
  10. }
  11.  
  12. void display(void)    {
  13.     glClear(GL_COLOR_BUFFER_BIT) ;
  14. }
  15.  
  16. void mouseButton(int button, int state, int x, int y) {
  17.     printf("mouseButton: %d %d %d %d\n", button, state, x, y);
  18. }
  19.  
  20. void mouseMotion(int x, int y) {
  21.     printf("Motion: %d %d\n", x, y);
  22. }
  23.  
  24. void mousePassiveMotion(int x, int y) {
  25.     printf("passiveMotion: %d %d\n", x, y);
  26. }
  27.  
  28.  
  29. void mouseEntry(int state) {
  30.     printf("Entry: %d \n", state);
  31. }
  32.  
  33. void keys(unsigned char key, int x, int y) {
  34.     printf("key down: %d\n", (int) key);
  35. }
  36.  
  37.  
  38. void keysUp(unsigned char key, int x, int y) {
  39.     printf("key up: %d\n", (int) key);
  40. }
  41.  
  42.  
  43. void idle() {
  44.     glutPostRedisplay();
  45. }
  46.  
  47.  
  48. int main(int argc, char** argv)    {
  49.     int test;
  50.     glutInit(&argc, argv);
  51.     glutInitWindowSize(400, 100);
  52.     glutInitWindowPosition(0, 0);
  53.     test = glutCreateWindow("Window event tests") ;
  54.     init();
  55.     glutDisplayFunc(display);
  56.     glutIdleFunc(idle);
  57.     glutMouseFunc(mouseButton);
  58.     glutMotionFunc(mouseMotion);
  59.     glutPassiveMotionFunc(mousePassiveMotion);
  60.     glutEntryFunc(mouseEntry);
  61.     glutKeyboardFunc(keys);
  62.     glutKeyboardUpFunc(keysUp);
  63.     glutPositionWindow(100,100);
  64.     glutPostRedisplay();
  65.     glutMainLoop();
  66.  
  67.     return 0 ;
  68. }
  69.